<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>

    <script>
        const str = '1ab2cab3';
        // i 忽略正则大小写 g 全局匹配
        // console.log(str.replace('ab', '*'), str);
        console.log(str.replace(/Ab/gi, '*'), str);

    </script>
</body>

</html>